<?php

/**
 * Gere les exceptions levees par le package Bundle
 *
 * @category   McCube
 * @package    Bundle
 * @author     Leiha Sellier <leiha.sellier@gmail.com>
 * @license    http://creativecommons.org/licenses/by/3.0/  CC BY 3.0
 * @link       http://code.google.com/p/mechanics-cubes/
 */
class McCube_Html_Form_Exception
     extends McCube_Exception{

    public function __construct($message, $errorCode, $extras=array()){
        parent::__construct($message, $errorCode, $extras);
        $this->_extraDatas = $extras;
        $this->buildRealMessage();
    }

    public function buildRealMessage(){
        switch($this->message){
            default             : $txt = $this->message; break;
            case 'Form:Field'   : $txt = 'Form Field';break;
        }

        $this->message  = $txt.' [ '
            .'[@value@'.$this->_extraDatas['fieldname'].'@]'
        .' ] '.$this->getLitteralCode();

        $this->message .= "\n".' - Bundle [ '.
            '[@bundle@'.$this->_extraDatas['bundle'].'@]'
        .' ]';

        $this->message .= ' Form [ '.
            '[@bundle@'.$this->_extraDatas['formname'].'@]'
        .' ]';
    }
}